<div class="dux-tools">
  <div class="bread-head">TAG管理 <span class="small">管理内容关键词分离的TAG标签</span> </div>
  <br>
  <div class="tools-function clearfix">
    <div class="float-left"> <a class="button button-small bg-main icon-list" href="__URL__"> TAG管理</a> </div>
    <div class="button-group float-right"> <a class="button button-small bg-dot icon-plus dropdown-toggle"> TAG分组 <span class="downward"></span></a>
      <ul class="drop-menu pull-right">
        <?php if(model('user_group')->model_power('tags','class_config')){ ?>
        <li><a href="__URL__/category">TAG分组管理</a></li>
        <li><a href="javascript:;" onClick="add()">添加TAG组</a></li>
    <?php } ?>
      </ul>
    </div>
  </div>
</div>
<div class="admin-main"> 
  <div class="panel dux-box">
    <div class="table-tools clearfix ">
      <div class="float-left">
          <div class="form-inline">
            <div class="form-group">
              <div class="field">
              <label>排序</label>
                <select id="sequence" onchange="javascript:location.href=this.value;" class="input">
                  <option value="__URL__/index/sequence-0" <?php if($_GET['sequence']==0){ ?> selected="selected" <?php } ?> >默认</option>
                  <option value="__URL__/index/sequence-1" <?php if($_GET['sequence']==1){ ?> selected="selected" <?php } ?> >点击率 高->低</option>
                  <option value="__URL__/index/sequence-2" <?php if($_GET['sequence']==2){ ?> selected="selected" <?php } ?> >点击率 低->高</option>
                </select>
              </div>
            </div>
            <div class="form-group">
              <div class="field">
              <label>分组筛选</label>
                <select id="catcory" onchange="javascript:location.href=this.value;" class="input">
                  <option value="__URL__/index" >全部</option>
                  <option value="__URL__/index/cid-0" <?php if(isset($_GET['cid'])&&$_GET['cid']==0){ ?> selected="selected" <?php } ?> >未分组</option>
                  <!--foreach:{$category_list $vo}--> 
                  <option value="__URL__/index/cid-{$vo.cid}"  <?php if($_GET['cid']==$vo['cid']){ ?> selected="selected" <?php } ?> >{$vo.name}</option>
                  <!--{/foreach}-->
                </select>
              </div>
            </div>
            <div class="form-group">
              <div class="field">
              <label>搜索</label>
                <input style="width:100px" name="search" type="text" class="input" id="search" value="<?php echo urldecode($_GET['search']) ?>" />
              </div>
            </div>
            <div class="form-button">
              <button class="button" type="button" onclick="javascript:location.href='__URL__/index/search-'+$('#search').val();">搜索</button>
            </div>
          </div>
      </div>
    </div>
    <div class="table-responsive">
      <table id="table" class="table table-hover ">
        <tbody>
          <tr>
            <th width="80">选择</th>
            <th width="*">编号</th>
            <th width="*">名称</th>
            <th width="*">分组</th>
            <th width="150">点击数</th>
          </tr>
          <!--foreach:{$list $vo}-->
          <tr>
            <td align="center"><center>
              <input name="id[]" type="checkbox" id="id[]" value="{$vo['id']}" ></td>
            <td>{$vo.id}</td>
            <td>{$vo.name}</td>
            <td>{$vo.cname}</td>
            <td><center>
                {$vo.click}
              </center></td>
          </tr>
          <!--{/foreach}-->
        </tbody>
      </table>
    </div>
    <div class="panel-foot table-foot clearfix">
      <div class="float-left">
        <div class="form-inline">
          <div class="form-button"> <a class="button bg-blue button-small" onclick="javascript:selectall('id[]');" type="button">全选</a>
          <?php if(model('user_group')->model_power('tags','del')){ ?>
          <a class="button bg-blue button-small" onclick="javascript:audit(1);" type="submit">删除</a>
          <?php } ?>
          <?php if(model('user_group')->model_power('tags','class')){ ?>
          <a class="button bg-blue button-small" onclick="javascript:$('#mobile').toggle();" type="submit">分组</a>
          <span id="mobile" style="display:none">
  			<select name="cid"  id="cid" class="input">
              <option value="0">选择分组</option>
              <!--foreach:{$category_list $vo}--> 
              <option value="{$vo['cid']}">
                  {$vo['name']}
              </option>
              <!--{/foreach}-->
            </select>
            <input type="button" onclick="javascript:audit(2);" class="button_small" value="确认" />
          </span>
          <?php } ?>
           </div>
        </div>
        <br>
      </div>
      <div class="float-right">
      	<div class="page_tool">
        <div class="page" >{$page}</div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
function add() {
	urldialog({
	title:'TAG分组添加',
	url:'__URL__/category_add'
	});
};
//选择
function selectall(name){   
    $("[name='"+name+"']").each(function(){//反选   
    if($(this).attr("checked")){   
          $(this).removeAttr("checked");   
    }else{   
          $(this).attr("checked",'true');   
    }   
    })  
}
//批量操作
function audit(status){
	var str="";
	$("[name='id[]']").each(function(){//反选   
    if($(this).attr("checked")){
		  str+=$(this).val()+","; 
    }
    })
	
	ajaxpost({
		name:'您确认要继续进行操作吗？操作将无法撤销！',
		url:"__URL__/batch",
		data:{status: status, id:str, cid:$('#cid').val()},
		tip:1,
		success:function(){
			window.location.reload();	
		}
	});
}
</script>